/**
 * 
 */
package com.cp16.tss.form;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;

import com.cp16.tss.handler.ServiceHandler;
import com.toedter.calendar.JDateChooser;

/**
 * @author GiangHN
 * @version 1.0
 * @since 01/01/2014
 * 
 */
public class ServiceEditForm extends JFrame implements ActionListener {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField txtServicePrice;
	private JTextField txtServiceId;
	private JTextField txtServiceName;
	private JDateChooser txtDateOfQuotation;
	private JPanel panel;
	private JLabel lblAddNewService;
	private JLabel lblServiceId;
	private JLabel lblServiceName;
	private JLabel lblPrice;
	private JLabel lblDateOfQuotation;
	private JLabel label;
	private JLabel label_1;
	private JButton btnClear;
	private JButton btnOK;
	private JLabel lblIdReq;
	private JLabel lblServiceNameReq;
	private JLabel lblVND;
	private JLabel label_2;
	private JLabel lblPriceReq;

	public ServiceEditForm() {
		loadLookAndFeel();
		initComponents();
	}

	private void loadLookAndFeel() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException ex) {
			Logger.getLogger(ServiceEditForm.class.getName()).log(Level.SEVERE,
					null, ex);
		} catch (InstantiationException ex) {
			Logger.getLogger(ServiceEditForm.class.getName()).log(Level.SEVERE,
					null, ex);
		} catch (IllegalAccessException ex) {
			Logger.getLogger(ServiceEditForm.class.getName()).log(Level.SEVERE,
					null, ex);
		} catch (UnsupportedLookAndFeelException ex) {
			Logger.getLogger(ServiceEditForm.class.getName()).log(Level.SEVERE,
					null, ex);
		}
	}

	private void initComponents() {

		setTitle("CustomerCare- created by Hoang Ngoc Giang");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(280, 150, 731, 296);
		setResizable(false);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(0, 191, 255));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		panel = new JPanel();
		panel.setBounds(10, 11, 705, 248);
		contentPane.add(panel);
		panel.setLayout(null);

		lblAddNewService = new JLabel("Add new a service");
		lblAddNewService.setFont(new Font("Tahoma", Font.PLAIN, 20));
		lblAddNewService.setBounds(251, 11, 341, 37);
		panel.add(lblAddNewService);

		lblServiceId = new JLabel("ID");
		lblServiceId.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblServiceId.setBounds(22, 70, 27, 29);
		panel.add(lblServiceId);

		txtServiceId = new JTextField();
		txtServiceId.setFont(new Font("Tahoma", Font.PLAIN, 13));
		txtServiceId.setColumns(10);
		txtServiceId.setBounds(87, 71, 103, 29);
		panel.add(txtServiceId);

		txtServicePrice = new JTextField();
		txtServicePrice.setFont(new Font("Tahoma", Font.PLAIN, 13));
		txtServicePrice.setBounds(87, 124, 141, 29);
		panel.add(txtServicePrice);
		txtServicePrice.setColumns(10);

		lblServiceName = new JLabel("Name");
		lblServiceName.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblServiceName.setBounds(302, 70, 49, 29);
		panel.add(lblServiceName);

		txtServiceName = new JTextField();
		txtServiceName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		txtServiceName.setColumns(10);
		txtServiceName.setBounds(427, 70, 254, 29);
		panel.add(txtServiceName);

		lblPrice = new JLabel("Price");
		lblPrice.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblPrice.setBounds(22, 124, 41, 29);
		panel.add(lblPrice);

		lblDateOfQuotation = new JLabel("Date of quotation");
		lblDateOfQuotation.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblDateOfQuotation.setBounds(302, 123, 126, 29);
		panel.add(lblDateOfQuotation);

		txtDateOfQuotation = new JDateChooser();
		txtDateOfQuotation.setDateFormatString("dd/MM/yyyy");
		txtDateOfQuotation.setFont(new Font("Tahoma", Font.PLAIN, 13));
		txtDateOfQuotation.setBounds(427, 124, 156, 29);
		panel.add(txtDateOfQuotation);

		label = new JLabel("*");
		label.setForeground(new Color(255, 0, 0));
		label.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label.setBounds(72, 70, 14, 29);
		panel.add(label);

		label_1 = new JLabel("*");
		label_1.setForeground(Color.RED);
		label_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label_1.setBounds(414, 70, 14, 29);
		panel.add(label_1);

		lblIdReq = new JLabel("");
		lblIdReq.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblIdReq.setBounds(101, 100, 197, 19);
		panel.add(lblIdReq);

		lblServiceNameReq = new JLabel("");
		lblServiceNameReq.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblServiceNameReq.setBounds(441, 100, 211, 19);
		panel.add(lblServiceNameReq);

		btnClear = new JButton("Clear");
		btnClear.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnClear.setBounds(353, 192, 89, 37);
		btnClear.addActionListener(this);
		panel.add(btnClear);

		btnOK = new JButton("Add");
		btnOK.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnOK.setBounds(251, 192, 89, 37);
		btnOK.addActionListener(this);
		panel.add(btnOK);

		lblVND = new JLabel("VND");
		lblVND.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblVND.setBounds(237, 124, 57, 29);
		panel.add(lblVND);

		label_2 = new JLabel("*");
		label_2.setForeground(Color.RED);
		label_2.setFont(new Font("Tahoma", Font.PLAIN, 15));
		label_2.setBounds(73, 124, 14, 29);
		panel.add(label_2);

		lblPriceReq = new JLabel("");
		lblPriceReq.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblPriceReq.setBounds(101, 154, 197, 19);
		panel.add(lblPriceReq);

	}

	/**
	 * @return the txtServicePrice
	 */
	public JTextField getTxtServicePrice() {
		return txtServicePrice;
	}

	/**
	 * @param txtServicePrice
	 *            the txtServicePrice to set
	 */
	public void setTxtServicePrice(JTextField txtServicePrice) {
		this.txtServicePrice = txtServicePrice;
	}

	/**
	 * @return the txtServiceId
	 */
	public JTextField getTxtServiceId() {
		return txtServiceId;
	}

	/**
	 * @param txtServiceId
	 *            the txtServiceId to set
	 */
	public void setTxtServiceId(JTextField txtServiceId) {
		this.txtServiceId = txtServiceId;
	}

	/**
	 * @return the txtServiceName
	 */
	public JTextField getTxtServiceName() {
		return txtServiceName;
	}

	/**
	 * @param txtServiceName
	 *            the txtServiceName to set
	 */
	public void setTxtServiceName(JTextField txtServiceName) {
		this.txtServiceName = txtServiceName;
	}

	/**
	 * @return the txtDateOfQuotation
	 */
	public JDateChooser getTxtDateOfQuotation() {
		return txtDateOfQuotation;
	}

	/**
	 * @param txtDateOfQuotation the txtDateOfQuotation to set
	 */
	public void setTxtDateOfQuotation(JDateChooser txtDateOfQuotation) {
		this.txtDateOfQuotation = txtDateOfQuotation;
	}

	/**
	 * @return the lblAddNewService
	 */
	public JLabel getLblAddNewService() {
		return lblAddNewService;
	}

	/**
	 * @param lblAddNewService
	 *            the lblAddNewService to set
	 */
	public void setLblAddNewService(JLabel lblAddNewService) {
		this.lblAddNewService = lblAddNewService;
	}

	/**
	 * @return the lblServiceId
	 */
	public JLabel getLblServiceId() {
		return lblServiceId;
	}

	/**
	 * @param lblServiceId
	 *            the lblServiceId to set
	 */
	public void setLblServiceId(JLabel lblServiceId) {
		this.lblServiceId = lblServiceId;
	}

	/**
	 * @return the lblServiceName
	 */
	public JLabel getLblServiceName() {
		return lblServiceName;
	}

	/**
	 * @param lblServiceName
	 *            the lblServiceName to set
	 */
	public void setLblServiceName(JLabel lblServiceName) {
		this.lblServiceName = lblServiceName;
	}

	/**
	 * @return the lblPrice
	 */
	public JLabel getLblPrice() {
		return lblPrice;
	}

	/**
	 * @param lblPrice
	 *            the lblPrice to set
	 */
	public void setLblPrice(JLabel lblPrice) {
		this.lblPrice = lblPrice;
	}

	/**
	 * @return the lblDateOfQuotation
	 */
	public JLabel getLblDateOfQuotation() {
		return lblDateOfQuotation;
	}

	/**
	 * @param lblDateOfQuotation
	 *            the lblDateOfQuotation to set
	 */
	public void setLblDateOfQuotation(JLabel lblDateOfQuotation) {
		this.lblDateOfQuotation = lblDateOfQuotation;
	}

	/**
	 * @return the label
	 */
	public JLabel getLabel() {
		return label;
	}

	/**
	 * @param label
	 *            the label to set
	 */
	public void setLabel(JLabel label) {
		this.label = label;
	}

	/**
	 * @return the label_1
	 */
	public JLabel getLabel_1() {
		return label_1;
	}

	/**
	 * @param label_1
	 *            the label_1 to set
	 */
	public void setLabel_1(JLabel label_1) {
		this.label_1 = label_1;
	}

	/**
	 * @return the btnClear
	 */
	public JButton getBtnClear() {
		return btnClear;
	}

	/**
	 * @param btnClear
	 *            the btnClear to set
	 */
	public void setBtnClear(JButton btnClear) {
		this.btnClear = btnClear;
	}

	/**
	 * @return the btnOK
	 */
	public JButton getBtnOK() {
		return btnOK;
	}

	/**
	 * @param btnOK the btnOK to set
	 */
	public void setBtnOK(JButton btnOK) {
		this.btnOK = btnOK;
	}

	/**
	 * @return the lblIdReq
	 */
	public JLabel getLblIdReq() {
		return lblIdReq;
	}

	/**
	 * @param lblIdReq
	 *            the lblIdReq to set
	 */
	public void setLblIdReq(JLabel lblIdReq) {
		this.lblIdReq = lblIdReq;
	}

	/**
	 * @return the lblServiceNameReq
	 */
	public JLabel getLblServiceNameReq() {
		return lblServiceNameReq;
	}

	/**
	 * @param lblServiceNameReq
	 *            the lblServiceNameReq to set
	 */
	public void setLblServiceNameReq(JLabel lblServiceNameReq) {
		this.lblServiceNameReq = lblServiceNameReq;
	}

	/**
	 * @return the lblVND
	 */
	public JLabel getLblVND() {
		return lblVND;
	}

	/**
	 * @param lblVND
	 *            the lblVND to set
	 */
	public void setLblVND(JLabel lblVND) {
		this.lblVND = lblVND;
	}

	/**
	 * @return the label_2
	 */
	public JLabel getLabel_2() {
		return label_2;
	}

	/**
	 * @param label_2
	 *            the label_2 to set
	 */
	public void setLabel_2(JLabel label_2) {
		this.label_2 = label_2;
	}

	/**
	 * @return the lblPriceReq
	 */
	public JLabel getLblPriceReq() {
		return lblPriceReq;
	}

	/**
	 * @param lblPriceReq
	 *            the lblPriceReq to set
	 */
	public void setLblPriceReq(JLabel lblPriceReq) {
		this.lblPriceReq = lblPriceReq;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		ServiceHandler serviceHandler = new ServiceHandler();
		if(e.getSource() == btnOK){
			serviceHandler.editService(this);
		}
	}

}
